import {ModalForm, ProFormText, ProFormSelect} from "@ant-design/pro-components";
import {PosterVO} from "@/services/PosterService";
import {useRef, useState} from "react";
import {ProFormInstance} from "@ant-design/pro-form/lib";
import {RequestOptionsType} from "@ant-design/pro-utils";
import {useModel, useSnapshot} from "@@/exports";
import {PosterModel} from "@/models/poster";


export interface PosterUpdateModalProps {
    onFinish: (formData: any) => Promise<boolean | void>;
}

const PosterUpdateModal = (props: PosterUpdateModalProps) => {
    let {getDictList} = useModel("dict");
    let posterState = useSnapshot(PosterModel.state);
    let {actions: posterActions} = PosterModel
    const formRef = useRef<ProFormInstance>()
    return <>
        <ModalForm
            key={posterState.poster?.id || -1}
            formRef={formRef}
            title={posterState.poster ? "修改海报" : "添加海报"}
            open={posterState.updateModalState}
            initialValues={posterState.poster}
            onFinish={props.onFinish}
            onOpenChange={posterActions.setUpdateModalState}
            >
            <ProFormText
                    label="海报id"
                    hidden
                    name="id"
                    rules={[{required: true, message: "请填写海报id"}]}
            />


            <ProFormText
                    label="链接地址"
                    name="picUrl"
                    rules={[{required: true, message: "请填写链接地址"}]}
            />


            <ProFormText
                    label="排序"
                    name="sort"
                    rules={[{required: true, message: "请填写排序"}]}
            />


            <ProFormText
                    label="租户id"
                    name="tenantId"
                    rules={[{required: true, message: "请填写租户id"}]}
            />


        </ModalForm>
    </>
}

export default PosterUpdateModal
